home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / gg243774.zip / PWFOLDER.ZIP / PWFOLDER.C < prev    next >
Text File  |  1992-04-09  |  29KB  |  694 lines

  1. /*************************************************************************/
  2. /*                                                                       */
  3. /* ITSC Redbook OS/2 v2.0 Sample Program                                 */
  4. /*                                                                       */
  5. /*                                                                       */
  6. /* PWFOLDER.C                                                            */
  7. /*                                                                       */
  8. /*                                                                       */
  9. /*************************************************************************/
  10.  
  11. /*
  12.  * This file was generated by the SOM Compiler.
  13.  * FileName: pwfolder.c.
  14.  * Generated using:
  15.  *     SOM Precompiler spc: 1.22
  16.  *     SOM Emitter emitc: 1.24
  17.  */
  18. #define INCL_WIN
  19. #define INCL_DOS
  20. #define INCL_GPIBITMAPS
  21. #define INCL_WPCLASS
  22. #define INCL_WPFOLDER
  23.  
  24. /******************************************************************************/
  25. /* System-defined header files                                                */
  26. /******************************************************************************/
  27. #include <os2.h>
  28.  
  29. #include <pmwp.h>  /* eventually will be #define INCL_WINWORKPLACE */
  30.  
  31. #include <string.h>
  32. #include <stdio.h>
  33. #include <memory.h>
  34. #include <stdlib.h>
  35.  
  36. /******************************************************************************/
  37. /* Function prototype for dialog proc                                         */
  38. /******************************************************************************/
  39. MRESULT EXPENTRY PasswordDlgProc(HWND hwndDlg,
  40.                                  ULONG msg,
  41.                                  MPARAM mp1,
  42.                                  MPARAM mp2);
  43.  
  44. /******************************************************************************/
  45. /* Dialog definitions header file                                             */
  46. /******************************************************************************/
  47. #include "dialog.h"
  48.  
  49. /******************************************************************************/
  50. /* Global data                                                                */
  51. /******************************************************************************/
  52. HMODULE  hmodThisClass;                          /* Module handle             */
  53. HPOINTER hLockedIcon;                            /* Handle for locked icon    */
  54. HPOINTER hUnlockedIcon;                          /* Handle for unlocked icon  */
  55.  
  56. PSZ      DefaultClassTitle = "Password Folder";  /* Default folder title      */
  57.  
  58.  
  59. #define PWFolder_Class_Source
  60. #include "pwfolder.ih"
  61.  
  62. /*
  63.  *
  64.  *   METHOD:   QueryInfo                                   PRIVATE
  65.  *
  66.  *   PURPOSE:  Copies instance data into the PWF_INFO structure.
  67.  *
  68.  *   INVOKED:  From PasswordDlgProc
  69.  *
  70.  */
  71.  
  72. SOM_Scope BOOL   SOMLINK pwfolder_QueryInfo(PWFolder *somSelf,
  73.                 PPWF_INFO pPWFolderInfo)
  74. {
  75.     PWFolderData *somThis =                      /* Get instance data pointer */
  76.            PWFolderGetData(somSelf);
  77.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  78.           "pwfolder_QueryInfo");
  79.  
  80.     strcpy(pPWFolderInfo->szCurrentPassword,     /* Set user-entered password */
  81.            _szCurrentPassword);
  82.     strcpy(pPWFolderInfo->szPassword,            /* Set folder password       */
  83.            _szPassword);
  84.     strcpy(pPWFolderInfo->szUserid,              /* Set userid                */
  85.            _szUserid);
  86.  
  87.     return (BOOL) 0;                             /* Return                    */
  88. }
  89.  
  90. /*
  91.  *
  92.  *   METHOD:   SetInfo                                     PRIVATE
  93.  *
  94.  *   PURPOSE:  Sets instance data from the PWF_INFO structure.
  95.  *
  96.  *   INVOKED:  From PasswordDlgProc
  97.  *
  98.  */
  99.  
  100. SOM_Scope BOOL   SOMLINK pwfolder_SetInfo(PWFolder *somSelf,
  101.                 PPWF_INFO pPWFolderInfo)
  102. {
  103.     PWFolderData *somThis =                      /* Get instance data pointer */
  104.            PWFolderGetData(somSelf);
  105.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  106.           "pwfolder_QueryInfo");
  107.  
  108.     strcpy(_szCurrentPassword,                   /* Save user-entered p'word  */
  109.            pPWFolderInfo->szCurrentPassword);
  110.     strcpy(_szPassword,                          /* Save folder password      */
  111.            pPWFolderInfo->szPassword);
  112.     strcpy(_szUserid,                            /* Save userid               */
  113.            pPWFolderInfo->szUserid);
  114.  
  115.     return (BOOL) 0;                             /* Return                    */
  116. }
  117.  
  118. /*
  119.  *
  120.  *   METHOD:   LockFolder                                  PUBLIC
  121.  *
  122.  *   PURPOSE:  Invalidates the current password, thereby locking the folder.
  123.  *
  124.  *   INVOKED:  From _wpMenuItemSelected
  125.  *
  126.  */
  127.  
  128. SOM_Scope BOOL   SOMLINK pwfolder_LockFolder(PWFolder *somSelf)
  129. {
  130.     BOOL bSuccess;
  131.  
  132.     PWFolderData *somThis =                      /* Get instance data pointer */
  133.            PWFolderGetData(somSelf);
  134.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  135.           "pwfolder_QueryInfo");
  136.  
  137.     strcpy(_szCurrentPassword,"NOPASSWD");       /* Invalid user-entered      */
  138.                                                  /* password                  */
  139.     _wpSetTitle(somSelf,                         /* Set folder title to       */
  140.                 _wpQueryTitle(somSelf) );        /* locked state              */
  141.  
  142.     bSuccess=_wpSetIcon(somSelf,                 /* Set icon to locked state  */
  143.                         hLockedIcon);
  144.  
  145.     _wpSaveImmediate(somSelf);                   /* Rember this state         */
  146.     return (BOOL) 0;                             /* Return                    */
  147. }
  148.  
  149. /*
  150.  *
  151.  *   METHOD:   wpInitData                                  PUBLIC
  152.  *
  153.  *   PURPOSE:  Initializes instance data
  154.  *
  155.  *   INVOKED:  By Workplace Shell, upon instantiation of the object instance.
  156.  *
  157.  */
  158.  
  159. SOM_Scope void   SOMLINK pwfolder_wpInitData(PWFolder *somSelf)
  160. {
  161.     CHAR  ErrorBuffer[100];
  162.  
  163.     PWFolderData *somThis =                      /* Get instance data pointer */
  164.                  PWFolderGetData(somSelf);
  165.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  166.                         "pwfolder_wpInitData");
  167.  
  168.     parent_wpInitData(somSelf);                  /* Invoke default processing */
  169.  
  170.     strcpy(_szCurrentPassword,"password");       /* Initialise folder in the  */
  171.     strcpy(_szPassword,"password");              /* unlocked state            */
  172. }
  173.  
  174. /*
  175.  *
  176.  *   METHOD:   wpModifyPopupMenu                           PUBLIC
  177.  *
  178.  *   PURPOSE:  Adds an additional "Lock" item to the object's context menu.
  179.  *
  180.  *   INVOKED:  By Workplace Shell, upon instantiation of the object instance.
  181.  *
  182.  */
  183.  
  184. SOM_Scope BOOL   SOMLINK pwfolder_wpModifyPopupMenu(PWFolder *somSelf,
  185.                 HWND hwndMenu,
  186.                 HWND hwndCnr,
  187.                 ULONG iPosition)
  188. {
  189.     PWFolderData *somThis =                      /* Get instance data pointer */
  190.                  PWFolderGetData(somSelf);
  191.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  192.                         "pwfolder_wpModifyPopupMenu");
  193.  
  194.     _wpInsertPopupMenuItems(somSelf,             /* Insert menu item          */
  195.                             hwndMenu,            /* Menu handle               */
  196.                             iPosition,           /* Default position          */
  197.                             hmodThisClass,       /* Module handle             */
  198.                             ID_CXTMENU_LOCK,     /* Menu item identifier      */
  199.                             0);                  /* No submenu identifier     */
  200.  
  201.     return(parent_wpModifyPopupMenu(somSelf,     /* Invoke default processing */
  202.                                     hwndMenu,
  203.                                     hwndCnr,
  204.                                     iPosition));
  205. }
  206.  
  207. /*
  208.  *
  209.  *   METHOD:   wpMenuItemSelected                          PUBLIC
  210.  *
  211.  *   PURPOSE:  Processes the user's selections from the context menu.  The
  212.  *             overridden method processes only the added "Lock" item, before
  213.  *             invoking the parent's default processing to handle other items.
  214.  *
  215.  *   INVOKED:  By Workplace Shell, upon selection of a menu item by the user.
  216.  *
  217.  */
  218.  
  219. SOM_Scope BOOL   SOMLINK pwfolder_wpMenuItemSelected(PWFolder *somSelf,
  220.                 HWND hwndFrame,
  221.                 ULONG ulMenuId)
  222. {
  223.     PWFolderData *somThis =                      /* Get instance data pointer */
  224.                  PWFolderGetData(somSelf);
  225.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  226.                         "pwfolder_wpMenuItemSelected");
  227.  
  228.     switch( ulMenuId )                           /* Switch on item identifier */
  229.     {
  230.        case IDM_LOCK:                            /* Lock item selected        */
  231.           _LockFolder(somSelf);                  /* Invoke _LockFolder method */
  232.           break;
  233.  
  234.        default:                                  /* All other items           */
  235.           parent_wpMenuItemSelected(somSelf,     /* Invoke default processing */
  236.                                     hwndFrame,
  237.                                     ulMenuId);
  238.           break;
  239.     }
  240. }
  241.  
  242. /*
  243.  *
  244.  *   METHOD:   wpOpen                                      PUBLIC
  245.  *
  246.  *   PURPOSE:  Only allows a folder to be opened if the folder is unlocked, or
  247.  *             if the user supplies the correct password in response to the
  248.  *             dialog.
  249.  *
  250.  *   INVOKED:  By Workplace Shell, upon selection of the "Open" menu item by
  251.  *             the user.
  252.  *
  253.  */
  254.  
  255. SOM_Scope HWND   SOMLINK pwfolder_wpOpen(PWFolder *somSelf,
  256.                 HWND hwndCnr,
  257.                 ULONG ulView,
  258.                 ULONG param)
  259. {
  260.     ULONG    ulResult;                           /* Return value              */
  261.     CHAR     szTitle[100];                       /* Folder title buffer       */
  262.     PVOID    pCreateParam;
  263.  
  264.     PWFolderData *somThis =                      /* Get instance data pointer */
  265.                  PWFolderGetData(somSelf);
  266.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  267.                         "pwfolder_wpOpen");
  268.  
  269.     if ((strcmp(_szCurrentPassword,              /* If folder is not locked   */
  270.          _szPassword)) == 0)
  271.     {
  272.         return(parent_wpOpen(somSelf,            /* Allow open to proceed in  */
  273.                              hwndCnr,            /* normal way using default  */
  274.                              ulView,             /* processing                */
  275.                              param));
  276.     }
  277.     pCreateParam = malloc( sizeof(ULONG) );      /* Allocate memory to pass a */
  278.                                                  /* ULONG to the dialog proc  */
  279.     *((PULONG)pCreateParam) = (ULONG)somSelf;    /* Put the somSelf pointer   */
  280.                                                  /* in the CreateParam memory */
  281.  
  282.     ulResult = WinDlgBox(HWND_DESKTOP,           /* Display password dialog   */
  283.                          HWND_DESKTOP,           /* Desktop is owner          */
  284.                          PasswordDlgProc,        /* Dialog procedure address  */
  285.                          hmodThisClass,          /* Module handle             */
  286.                          ID_DLG_PASSWORD,        /* Dialog resource id        */
  287.                          pCreateParam );         /* Create Param holding the  */
  288.                                                  /* pointer to this object    */
  289.  
  290.     if (ulResult == DID_OK )                     /* If user hit OK button     */
  291.        {
  292.        if ((strcmp(_szCurrentPassword,           /* If password is correct    */
  293.                    _szPassword)) == 0)
  294.           {
  295.           strcpy(szTitle,                        /* Get title string          */
  296.                  _wpQueryTitle(somSelf));
  297.           szTitle[strlen(szTitle)-9] = '\0';     /* Remove <LOCKED>           */
  298.           _wpSetTitle(somSelf,szTitle);          /* Reset title string        */
  299.  
  300.           _wpSetIcon(somSelf,                    /* Set icon to unlocked      */
  301.                      hUnlockedIcon);             /* state                     */
  302.  
  303.           return(parent_wpOpen(somSelf,          /* Allow open to proceed in  */
  304.                                hwndCnr,          /* normal way using default  */
  305.                                ulView,           /* processing                */
  306.                                param));
  307.           }
  308.        else                                      /* Password is incorrect     */
  309.           {
  310.           WinMessageBox(HWND_DESKTOP,            /* Display message to user   */
  311.                         HWND_DESKTOP,
  312.                         "Password incorrect. Folder remains locked.",
  313.                         "Password Failed",
  314.                         0,
  315.                         MB_OK |
  316.                         MB_CUAWARNING );
  317.           return((HWND)0);                       /* Return NULL handle        */
  318.           }
  319.        }
  320. }
  321.  
  322. /*
  323.  *
  324.  *   METHOD:   wpSetTitle                                  PUBLIC
  325.  *
  326.  *   PURPOSE:  Sets the folder's title (icon text) to have the phrase <Locked>
  327.  *             as a suffix if the folder is locked, or removes this suffix if
  328.  *             the folder is unlocked.
  329.  *
  330.  *   INVOKED:  By wpOpen to set the unlocked state, and by LockFolder to set
  331.  *             the locked state.
  332.  *
  333.  */
  334.  
  335. SOM_Scope BOOL   SOMLINK pwfolder_wpSetTitle(PWFolder *somSelf,
  336.                 PSZ pszNewTitle)
  337. {
  338.     CHAR szBuf[100];                             /* Character buffer          */
  339.  
  340.     PWFolderData *somThis =                      /* Get instance data pointer */
  341.                  PWFolderGetData(somSelf);
  342.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  343.                         "pwfolder_wpSetTitle");
  344.  
  345.     strcpy(szBuf,pszNewTitle);                   /* Get current title         */
  346.  
  347.     if ((strcmp(_szCurrentPassword,              /* If folder is locked       */
  348.                 _szPassword)) != 0)
  349.     {
  350.        if ((strstr(szBuf,"LOCKED")) == NULL)     /* and <LOCKED> not in       */
  351.        {                                         /* current title             */
  352.           strcat(szBuf," <LOCKED>");             /* Add <LOCKED> to title     */
  353.        }
  354.     }
  355.     return (parent_wpSetTitle(somSelf,szBuf));   /* Invoke default processing */
  356. }
  357.  
  358. /*
  359.  *
  360.  *   METHOD:   wpSetup                                     PUBLIC
  361.  *
  362.  *   PURPOSE:  Sets folder properties based upon a setup string passed by the
  363.  *             object's creator as part of the WinCreateObject() call.  The
  364.  *             overridden method simply processes the PASSWORD keyword to set
  365.  *             the folder's password immediately upon instantiation, before
  366.  *             invoking the parent's default processing to handle all other
  367.  *             keywords.
  368.  *
  369.  *   INVOKED:  By the Workplace Shell, upon instantiation of the object
  370.  *             instance.
  371.  *
  372.  */
  373.  
  374. SOM_Scope BOOL   SOMLINK pwfolder_wpSetup(PWFolder *somSelf,
  375.                 PSZ pszSetupString)
  376. {
  377.     CHAR  pszInitPword[20];                      /* Character buffer          */
  378.     BOOL  bFound;                                /* Success flag              */
  379.     ULONG Length;                                /* Returned length           */
  380.  
  381.     PWFolderData *somThis =                      /* Get instance data pointer */
  382.                  PWFolderGetData(somSelf);
  383.     PWFolderMethodDebug("PWFolder",              /* Get debug info            */
  384.                         "pwfolder_wpSetup");
  385.  
  386.     if (*pszSetupString != '\0')                 /* If string is present      */
  387.        {
  388.        bFound=_wpScanSetupString(somSelf,        /* Parse setup string to     */
  389.                                  pszSetupString, /* find PASSWORD keyword     */
  390.                                  "PASSWORD",
  391.                                  pszInitPword,   /* Buffer for keyword value  */
  392.                                  &Length);       /* Length of returned string */
  393.  
  394.        if (bFound)
  395.           {
  396.           strcpy(_szPassword,                    /* Initialize folder         */
  397.                  pszInitPword);                  /* password                  */
  398.           strcpy(_szCurrentPassword,             /* Initialize user-entered   */
  399.                  pszInitPword);                  /* password                  */
  400.           }
  401.        }
  402.     return(parent_wpSetup(somSelf,               /* Invoke default processing */
  403.                           pszSetupString));
  404. }
  405.  
  406. /*
  407.  *
  408.  *   METHOD:   wpSaveState                                 PUBLIC
  409.  *
  410.  *   PURPOSE:  Saves the object instance's persistent state data.  The
  411.  *             overridden method simply saves the password data, then invokes
  412.  *             the parent's default processing to handle any other instance
  413.  *             data defined by ancestor classes.
  414.  *
  415.  *   INVOKED:  By the Workplace Shell, when the object becomes dormant.
  416.  *
  417.  */
  418.  
  419. SOM_Scope BOOL   SOMLINK pwfolder_wpSaveState(PWFolder *somSelf)
  420. {
  421.     PWFolderData *somThis =                      /* Get instance data pointer */
  422.                  PWFolderGetData(somSelf);
  423.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  424.                         "pwfolder_wpSaveState");
  425.  
  426.     _wpSaveString(somSelf,                       /* Save folder password      */
  427.                   "PWFolder",                    /* Class name                */
  428.                   1L,                            /* Class-defined key         */
  429.                   _szPassword);                  /* String to be saved        */
  430.     _wpSaveString(somSelf,                       /* Save user-entered p'word  */
  431.                   "PWFolder",                    /* Class name                */
  432.                   2L,                            /* Class-defined key         */
  433.                   _szCurrentPassword);           /* String to be saved        */
  434.  
  435.     return(parent_wpSaveState(somSelf));         /* Invoke default processing */
  436. }
  437.  
  438. /*
  439.  *
  440.  *   METHOD:   wpRestoreState                              PUBLIC
  441.  *
  442.  *   PURPOSE:  Restores the object instance's persistent state data.  The
  443.  *             overridden method simply restores the password data, then
  444.  *             invokes the parent's default processing to handle any other
  445.  *             instance data defined by ancestor classes.
  446.  *
  447.  *   INVOKED:  By the Workplace Shell, when the object becomes awake.
  448.  *
  449.  */
  450.  
  451. SOM_Scope BOOL   SOMLINK pwfolder_wpRestoreState(PWFolder *somSelf,
  452.                 ULONG ulReserved)
  453. {
  454.     ULONG ulRetLength;                           /* Length of returned string */
  455.  
  456.     PWFolderData *somThis =                      /* Get instance data pointer */
  457.                  PWFolderGetData(somSelf);
  458.     PWFolderMethodDebug("PWFolder",              /* Set debug info            */
  459.                         "pwfolder_wpRestoreState");
  460.  
  461.     _wpRestoreString(somSelf,                    /* Restore folder password   */
  462.                      "PWFolder",                 /* Class name                */
  463.                      1L,                         /* Class-defined key         */
  464.                      _szPassword,                /* String to be restored     */
  465.                      &ulRetLength);              /* Length of returned string */
  466.     _wpRestoreString(somSelf,                    /* Restore user-entered pwd  */
  467.                      "PWFolder",                 /* Class name                */
  468.                      2L,                         /* Class-defined key         */
  469.                      _szCurrentPassword,         /* String to be restored     */
  470.                      &ulRetLength);              /* Length of returned string */
  471.  
  472.     if ((strcmp(_szCurrentPassword,              /* If folder is locked       */
  473.                 _szPassword)) != 0)
  474.     {
  475.        _wpSetIcon(somSelf, hLockedIcon);         /* Set icon to locked state  */
  476.     }
  477.  
  478.     return(parent_wpRestoreState(somSelf,        /* Invoke default processing */
  479.                                  ulReserved));
  480. }
  481.  
  482. /*
  483.  *
  484.  *   METHOD:   wpSetIcon                                   PUBLIC
  485.  *
  486.  *   PURPOSE:  This class method returns the handle to the correct icon for
  487.  *             the object.
  488.  *
  489.  *   INVOKED:
  490.  *
  491.  */
  492.  
  493. SOM_Scope BOOL   SOMLINK pwfolder_wpSetIcon(PWFolder *somSelf,
  494.                 HPOINTER hptrNewIcon)
  495. {
  496.     PWFolderData *somThis = PWFolderGetData(somSelf);
  497.     PWFolderMethodDebug("PWFolder","pwfolder_wpSetIcon");
  498.  
  499.     if ((strcmp(_szCurrentPassword,         /* If password is correct     */
  500.                 _szPassword)) == 0)
  501.     {
  502.        return (parent_wpSetIcon(somSelf,
  503.                      hUnlockedIcon));       /* return pointer to unlocked */
  504.     }
  505.     else                                    /* otherwise                  */
  506.     {
  507.        return (parent_wpSetIcon(somSelf,
  508.                      hLockedIcon));         /* return locked icon pointer */
  509.     }
  510. }
  511.  
  512. #undef SOM_CurrentClass
  513. #define SOM_CurrentClass SOMMeta
  514. /*
  515.  *
  516.  *   METHOD:   wpclsQueryTitle                             PUBLIC
  517.  *
  518.  *   PURPOSE:  This class method returns the default folder title for any
  519.  *             instance of the password protected folder class.  This title
  520.  *             is used if a title is not supplied in the WinCreateObject()
  521.  *             call.
  522.  *
  523.  *   INVOKED:  By the Workplace Shell, upon instantiation of the object
  524.  *             instance.
  525.  *
  526.  */
  527.  
  528. SOM_Scope PSZ   SOMLINK pwfoldercls_wpclsQueryTitle(M_PWFolder *somSelf)
  529. {
  530.     /* M_PWFolderData *somThis = M_PWFolderGetData(somSelf); */
  531.  
  532.     M_PWFolderMethodDebug("M_PWFolder",          /* Set debug info            */
  533.                           "pwfoldercls_wpclsQueryTitle");
  534.  
  535.     return(DefaultClassTitle);                   /* Return default title      */
  536. }
  537.  
  538. /*
  539.  *
  540.  *   METHOD:   wpclsQueryIcon                              PUBLIC
  541.  *
  542.  *   PURPOSE:  This class method returns the handle to the default icon for
  543.  *             the class.  This method is not used in the current version,
  544.  *             but could be used if different icons are to be used for the
  545.  *             locked and unlocked states.
  546.  *
  547.  *   INVOKED:
  548.  *
  549.  */
  550.  
  551. SOM_Scope HPOINTER   SOMLINK pwfoldercls_wpclsQueryIcon(M_PWFolder *somSelf)
  552. {
  553.     /* M_PWFolderData *somThis = M_PWFolderGetData(somSelf); */
  554.     PWFolderData *somThis =                      /* Get instance data pointer */
  555.                  PWFolderGetData(somSelf);
  556.  
  557.     M_PWFolderMethodDebug("M_PWFolder",          /* Set debug info            */
  558.                           "pwfoldercls_wpclsQueryIcon");
  559.  
  560.     return(hUnlockedIcon);
  561. }
  562.  
  563. /*
  564.  *
  565.  *   METHOD:   wpclsInitData                               PUBLIC
  566.  *
  567.  *   PURPOSE:  This class method allows the initialization of any class data
  568.  *             items.  The overridden method simply obtains a module handle
  569.  *             to be used when accessing Presentation Manager resources, then
  570.  *             invokes the parent's default processing.
  571.  *
  572.  *   INVOKED:  By the Workplace Shell, upon loading the class DLL.
  573.  *
  574.  */
  575.  
  576. SOM_Scope void   SOMLINK pwfoldercls_wpclsInitData(M_PWFolder *somSelf)
  577. {
  578.     CHAR  ErrorBuffer[100];                      /* Error buffer              */
  579.  
  580.     /* M_PWFolderData *somThis = M_PWFolderGetData(somSelf); */
  581.  
  582.     M_PWFolderMethodDebug("M_PWFolder",          /* Set debug info            */
  583.                           "pwfoldercls_wpclsInitData");
  584.  
  585.     DosLoadModule((PSZ) ErrorBuffer,             /* Obtain DLL module handle  */
  586.                   sizeof(ErrorBuffer),
  587.                   "PWFOLDER",                    /* Module name               */
  588.                   &hmodThisClass);                       /* Module handle             */
  589.  
  590.     hLockedIcon=WinLoadPointer(HWND_DESKTOP,     /* Load icons                */
  591.                                hmodThisClass,
  592.                                ID_LOCK);
  593.     hUnlockedIcon=WinLoadPointer(HWND_DESKTOP,
  594.                                  hmodThisClass,
  595.                                  ID_UNLOCK);
  596.  
  597.     parent_wpclsInitData(somSelf);               /* Invoke default processing */
  598. }
  599.  
  600. /*
  601.  *
  602.  *   METHOD:   wpclsUnInitData                             PUBLIC
  603.  *
  604.  *   PURPOSE:  This class method allows the release of any class data items
  605.  *             or resources.  The overridden method releases the module handle
  606.  *             obtained by wpclsInitData, then invokes the parent's default
  607.  *             processing.
  608.  *
  609.  *   INVOKED:  By the Workplace Shell, upon unloading the class DLL.
  610.  *
  611.  */
  612.  
  613. SOM_Scope void   SOMLINK pwfoldercls_wpclsUnInitData(M_PWFolder *somSelf)
  614. {
  615.     /* M_PWFolderData *somThis = M_PWFolderGetData(somSelf); */
  616.  
  617.     M_PWFolderMethodDebug("M_PWFolder",          /* Set debug info            */
  618.                           "pwfoldercls_wpclsUnInitData");
  619.  
  620.     WinDestroyPointer(hLockedIcon);              /* Free icons                */
  621.     WinDestroyPointer(hUnlockedIcon);
  622.  
  623.     DosFreeModule(hmodThisClass);                        /* Free module handle        */
  624.  
  625.     parent_wpclsUnInitData(somSelf);
  626. }
  627.  
  628. /******************************************************************************/
  629. /*                                                                            */
  630. /* PROCEDURE NAME:  PasswordDlgProc                                           */
  631. /*                                                                            */
  632. /* description:  Dialog procedure for password dialog                         */
  633. /*                                                                            */
  634. /* invoked:  By Presentation Manager, in response to folder issuing           */
  635. /*           WinDlgBox() call from _wpOpen method.                            */
  636. /*                                                                            */
  637. /******************************************************************************/
  638. MRESULT EXPENTRY PasswordDlgProc(HWND hwndDlg,
  639.                                  ULONG msg,
  640.                                  MPARAM mp1,
  641.                                  MPARAM mp2)
  642. {
  643.    PWFolder *aPWF;                               /* Define SOM pointer        */
  644.    PWF_INFO pwfolderInfo;                        /* Define password structure */
  645.    CHAR     szTemp[100];                         /* Character buffer          */
  646.  
  647.    switch (msg)                                  /* Determine message class   */
  648.    {
  649.       case WM_INITDLG:                           /* Dialog being initialized  */
  650.  
  651.          WinSetWindowULong(hwndDlg,              /* Store SOM pointer in      */
  652.                           QWL_USER,              /* window word QWL_USER      */
  653.                           *((PULONG)mp2));
  654.          free(mp2);                              /* Free Create Param memory  */
  655.          break;
  656.  
  657.       case WM_COMMAND:                           /* User hit a pushbutton     */
  658.  
  659.          aPWF = (PWFolder *)WinQueryWindowULong(hwndDlg, QWL_USER);
  660.  
  661.          _QueryInfo(aPWF,                        /* Get password data         */
  662.                     &pwfolderInfo);
  663.  
  664.          switch (SHORT1FROMMP(mp1))              /* Which button was hit?     */
  665.          {
  666.             case DID_OK:                         /* Okay button               */
  667.  
  668.                WinQueryDlgItemText(hwndDlg,      /* Get text from entryfield  */
  669.                             ID_EF_PASSWORD,
  670.                             sizeof(szTemp),
  671.                             (PSZ)szTemp);
  672.  
  673.                                                  /* Copy to password data     */
  674.                strcpy(pwfolderInfo.szCurrentPassword, szTemp);
  675.  
  676.                _SetInfo(aPWF,&pwfolderInfo);     /* Set instance data         */
  677.                WinDismissDlg(hwndDlg,DID_OK);    /* Dismiss dialog            */
  678.                break;
  679.  
  680.             case DID_CANCEL:                     /* Cancel button hit         */
  681.  
  682.                WinDismissDlg(hwndDlg,            /* Dismiss dialog            */
  683.                              DID_CANCEL);
  684.                break;
  685.          }
  686.          return(MRESULT)TRUE;                    /* Return from WM_COMMAND    */
  687.          break;
  688.    }
  689.    return(WinDefDlgProc(hwndDlg,                 /* Invoke default PM message */
  690.                         msg,                     /* handling                  */
  691.                         mp1,
  692.                         mp2));
  693. }
  694.